<template>
	<div class="app-store">
		<div class="main">
			<iframe ref="refIframeAppStore" :src="frameSrc" frameborder="0" width="100%" height="100%"></iframe>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				frameSrc: ''
			}
		},
		created() {
			//根据路由中的path参数，拼接iframe地址
			this.iframeLoad()
		},
		methods: {
			iframeLoad() {
				// console.log('appstore 页 加载完成');
				// let iframe = this.$refs.refIframeAppStore;
				// let iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
				// let paasToken = sessionStorage.getItem('paas-token')
				// iframeWin.postMessage(paasToken, '*');
				let path = this.$route.query.path;
				console.log('加载AppStore.vue, path=', path);
				let paasToken = sessionStorage.getItem('paas-token');
				this.frameSrc = `${API.APP_STORE}${path}?token=${paasToken}&t=${Date.now()}`
			}
		},
		watch: {
			$route(to, from) {
				console.log('AppStore---watch方法', to, from);
				this.iframeLoad()
			}
		}

	}
</script>

<style lang="scss" scoped>
	.app-store {
		height: calc(100vh - 80px);
		background: #f8f8f8;
	
		.main {
			height: 100%;
			background-color: white;
			overflow-y: hidden;
			box-sizing: border-box;
			position: relative;
		}
	}
</style>